eth_estimateUserOperationGas
This method is used to estimate the gas required to send a user operation.
Parameters
userOperation
: A JSON object representing the user operation to estimate the gas for.entryPoint
: The entry point to use for the user operation.stateOverrides
: An optional JSON object representing the state overrides for the user operation.
note
The preVerificationGas
, verificationGasLimit
, callGasLimit
, paymasterVerificationGasLimit
, and paymasterPostOpGasLimit
fields of the user operation are ignored and therefore are not required.
note
During estimation, the sender
's balance is overriden. This allows to estimate gas requirements regardless of the actual balance of the sender.
Returns
A JSON object with the following properties:
preVerificationGas
: The estimated gas required for the pre-verification phase of the user operation.verificationGasLimit
: The estimated gas required for the verification phase of the user operation.callGasLimit
: The estimated gas required for the call phase of the user operation.paymasterVerificationGasLimit
: The estimated gas required for the paymaster verification phase of the user operation.paymasterPostOpGasLimit
: The estimated gas required for the paymaster post-operation phase of the user operation.
note
The paymasterVerificationGasLimit
and paymasterPostOpGasLimit
are only present if the user operation has a paymaster.
Example Request with state overrides
{
"jsonrpc":"2.0",
"id":1,
"method":"eth_estimateUserOperationGas",
"params":[
{
"sender":"0x1234567890123456789012345678901234567890",
"nonce":"0x1",
"factory":"0x1234567890123456789012345678901234567890",
"factoryData":"0x123456",
"callData":"0x123456",
"maxFeePerGas":"0x123456",
"maxPriorityFeePerGas":"0x123456",
"paymaster":"0x1234567890123456789012345678901234567890",
"paymasterData":"0x123456",
"signature":"0x123456"
},
"0x0000000071727De22E5E9d8BAf0edAc6f37da032",
{
"0x1234567890123456789012345678901234567890": {
"nonce": "0x2",
"balance": "0x1000000000000000000000000000000000000000"
}
}
]
}
Example Response
{
"jsonrpc":"2.0",
"id":1,
"result":{
"preVerificationGas": "0x123456",
"verificationGasLimit": "0x123456",
"callGasLimit": "0x123456",
"paymasterVerificationGasLimit": "0x123456",
"paymasterPostOpGasLimit": "0x123456"
}
}